<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首媒管理平台</title>
    <meta name="keywords" content="首媒后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="首媒是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
	<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT"> 
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}" rel="stylesheet">
    <link href="${ctx}/static/css/font-awesome.min.css?v=${static_version}" rel="stylesheet">
    <link href="${ctx}/static/css/animate.min.css?v=${static_version}" rel="stylesheet">
    <link href="${ctx}/static/css/style.min.css?v=${static_version}" rel="stylesheet"><base target="_blank">
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="gray-bg">
    <div class="middle-box text-center animated fadeInDown">
        <div>
            <div class="m-b-md">
                <img alt="image" class="img-circle circle-border" src="${ctx}/static/img/logo.jpg"  width="200" height="200">
            </div>
            <h3>商户管理系统</h3>
            <form role="form" >
            	<p class="text-muted text-center red-check" id="alertInfo"></p>
                <div class="form-group">
                    <input type="username" id="username" value="admin" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"  class="form-control" placeholder="登录名" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="password" value="admin" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"  class="form-control" placeholder="密码" required="">
                </div>
                <button type="button" onclick="submitForm()" class="btn btn-primary block full-width m-b">登 录</button>
                <p class="text-muted text-center"><a href="${ctx}/forgetPassword"><small>忘记密码了？</small></a></p>
            </form>
        </div>
    </div>
    
    <script>var ctx="${ctx}";</script>
    <script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
    <script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
    <script src="${ctx}/static/js/cookie.js?v=${static_version}"></script>
    <script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	<script>
	
		$(function(){
			$(".gray-bg").keydown(function(event){if (event.keyCode==13)submitForm();});
		})
	
		var submitForm=function(){
			$.ajax({
			    type: 'POST',
			    url: ctx+"/login",
			    data: {
			    	username:$("#username").val(),
			    	password:$("#password").val()
			    } ,
			    dataType: "json",
			    success:function(data){
			    	if(data.code==0){
			    		cookie("token",data.data.token,400000);
			    		window.location.href=ctx+"/index";
			    	}else if(data.code==3 ||data.code==5){
			    		$("#alertInfo").html("用户不存在或用户名错误.请重试");
					}else if(data.code==4){
						$("#alertInfo").html("用户密码错误.请重试");
			    	}else if(data.code==30){
			    		$("#alertInfo").html("商户没通过审核，请联系管理员");
			    	}
			    }
			});
		}
		
		$('#username').bind('input propertychange', function() {
			$("#alertInfo").html("");
		});
		
		$('#password').bind('input propertychange', function() {
			$("#alertInfo").html("");
		}); 
		
	</script>
</body>
</html>